package com.butterfly.hotkey.dashboard.framework.netty.handler;

import com.butterfly.hotkey.common.factory.CommonFactoryBean;
import com.butterfly.hotkey.common.netty.INettyMsgHandler;
import com.butterfly.hotkey.core.constant.Constants;
import com.butterfly.hotkey.core.model.msg.HotKeyMsg;
import io.netty.channel.ChannelHandlerContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import static com.butterfly.hotkey.dashboard.constant.FactoryConstant.HANDLER;
import static com.butterfly.hotkey.core.constant.MsgTypeConst.APP_CONNECT;

/**
 * 客户端上报自己的appName
 *
 * @author butterfly
 */
@Component
@CommonFactoryBean(type = HANDLER, valueInt = APP_CONNECT)
public class AppConnectNettyMsgHandler implements INettyMsgHandler {

    private static final Logger log = LoggerFactory.getLogger(Constants.DASHBOARD);

    @Override
    public void handle(HotKeyMsg message, ChannelHandlerContext context) {
        String appName = message.getAppName();

        // TODO 保存worker地址及app配置信息
    }

}
